<template>
	<view>
		<u-popup :show="switchRole" mode="center" :safeAreaInsetBottom="false" @close="closeSwitch"
			bgColor="transparent">
			<view class="popup1">
				<view class="close fs24" @click="closeSwitch">关闭</view>
				<view style="padding: 1px;"></view>
				<view class="fs40 fwb col1">选择身份</view>
				<view class="mt10 fs24 col89 lh28">选择您的身份，以便为您推荐更精准的内容</view>
				<template v-if="!userinfo || userinfo.group_id==2">
					<view class="mt70 switch_item" @click="nav(1)">
						<image src="/static/public/switch1.png" mode="aspectFill"></image>
						<view class="view flex flex-col flex-center">
							<view class="fs40 fwb">人才</view>
							<view class="mt10 fs30">我要找工作</view>
						</view>
					</view>
				</template>
				<template v-if="!userinfo || userinfo.group_id==1">
					<view  class="mt50 switch_item" @click="nav(2)">
						<image src="/static/public/switch2.png" mode="aspectFill"></image>
						<view class="view flex flex-col flex-center">
							<view class="fs40 fwb">用人单位</view>
							<view class="mt10 fs30">我要招人才</view>
						</view>
					</view>
				</template>
				
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		name: "change",
		props: {
			switchRole: {
				type: Boolean,
				default: false
			},
			userinfo: {
				type: Object,
				default: null
			}
		},
		data() {
			return {
			
			};
		},
		methods: {
			closeSwitch() {
				// this.switchRole = false
				this.$emit('close')
			},
			nav(groupId){
				if(groupId == 2){
					// this.$core.post({url:'xilujob.user/switch_group',data:{group_id: 2},success: ret=>{
					// 	console.log(ret)
					// 	this._loginSuccess(ret.data.userinfo)
					// }})
					uni.navigateTo({
						url: '/pages/public/login2'
					})
				}else{
					uni.navigateTo({
						url: '/pages/public/login'
					})
				}
				this.$emit('close')
			},
			_loginSuccess(userinfo) {
				getApp().globalData.userinfo = userinfo;
			    this.$core.setUserinfo(userinfo);
			    this.$chatIM.connectSocket();
				//如果是用户，或者是企业已审核通过的
			    if(userinfo.group_id==1 || userinfo.group_model.audit_status==1) {
			      if(getCurrentPages().length===1) {
			      }else {
			        uni.navigateBack({delta:2});
			      }
			    }else {
			      uni.reLaunch({url:'/pages/company/improve_corporate_information'});
			    }
			    uni.$emit(getApp().globalData.Events.UserLogin, userinfo);
			  },
		}
	}
</script>

<style lang="scss" scoped>
	.popup1 {
		width: 600rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		position: relative;
		padding: 70rpx 65rpx;
	z-index: 999999;
		.close {
			position: absolute;
			top: 30rpx;
			right: 30rpx;
		}
	
		.switch_item {
			width: 470rpx;
			height: 180rpx;
			position: relative;
	z-index: 9999999;
			image {
				width: 470rpx;
				height: 180rpx;
				position: absolute;
				top: 0;
				left: 0;
				z-index: 1;
			}
	
			.view {
				width: 470rpx;
				height: 180rpx;
				position: absolute;
				top: 0;
				left: 0;
				z-index: 22;
				padding: 0 30rpx;
				color: #FFFFFF;
				background: transparent;
			}
		}
	}
	.lh50{height: 50rpx;line-height: 1.2;}
</style>